package finalProject;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.WritableComparable;


public class Path implements WritableComparable<Path> {

	private Text path;
	private NounPair nounPair;
	
	public Path() {}
	
	public Path(Text path, NounPair nounPair)
	{
		this.path = path;
		this.nounPair = nounPair;
	}
	
	@Override
	public void readFields(DataInput in) throws IOException {
		String[] input = in.readUTF().split("\t");
		this.path = new Text(input[0]);
		this.nounPair = new NounPair(input[1], input[2]);
	}

	@Override
	public void write(DataOutput out) throws IOException {
		out.writeUTF(path + "\t" + this.nounPair.getNPx() + "\t" + this.nounPair.getNPy());
		 
	}

	@Override
	public int compareTo(Path other) {
		int ans = 0;
		ans = this.path.toString().compareTo(other.path.toString());
		if(ans == 0)
		{
			ans = this.nounPair.compareTo(other.nounPair);
		}
		return ans;
	}

	public Text getPath() {
		return path;
	}

	public NounPair getNounPair() {
		return nounPair;
	}
	
	

}
